package server;

import common.Level;
import common.PlayerEvent;

public abstract class GameControllerState {

	
	protected UpdateableGame game;
	protected Level level;
	protected GameController controller;
	
	
	public void initializeState(GameController c) {
		controller = c;
		game = c.getGame();
		level = c.getLevel();
	}
	
	public void timerTick(int tickCount) {
		// default state implementation does nothing
	}
	
	public void playerAttached(UpdateablePlayer player) {
		// default state implementation does nothing
	}
	
	public void playerDetached(UpdateablePlayer player) {
		game.setMessage("player " + player.GetName() + " has left the game. waiting for a new player...");
		controller.setState(new GameStateWaitingForPlayers());
	}
	
	public void playerEvent(UpdateablePlayer player, PlayerEvent event) {
		// default state implementation does nothing
	}
	
	
//	public boolean triggerStateTransition() {
//		return false;
//	}
	
//	public abstract GameControllerState nextState();
	
	/**
	 * this function will be called on the actual state class short before 
	 * a transition to a new state. this gives a state the chance to 
	 * do some cleanup... 
	 */
	public void detachState() {
	}
}
